package com.boliq.demo.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;

import blq.ssnb.baseconfigure.simple.MenuBean;
import blq.ssnb.baseconfigure.simple.SimpleMenuActivity;

/**
 * <pre>
 * ================================================
 * 作者: BLQ_SSNB
 * 日期：2021/2/25
 * 邮箱: blq_ssnb@outlook.com
 * 修改次数: 1
 * 描述:
 *      添加描述
 * ================================================
 * </pre>
 */
public class SingleInstanceActivity extends SimpleMenuActivity {
    private static final String BUNDLE_KEY_TITLE = "bundle_key_title";
    private static final String BUNDLE_KEY_INDEX = "bundle_key_index";

    public static Intent newIntent(Context context, String title, int index) {
        Intent intent = new Intent(context, SingleInstanceActivity.class);
        intent.putExtra(BUNDLE_KEY_INDEX, index + 1);
        intent.putExtra(BUNDLE_KEY_TITLE, title);
        return intent;
    }

    private int index;
    private String title;

    @Override
    protected void initBundle(@NonNull Bundle extras) {
        super.initBundle(extras);
        index = extras.getInt(BUNDLE_KEY_INDEX, 0);
        title = extras.getString(BUNDLE_KEY_TITLE, "standard");
    }

    @Override
    protected String navigationTitle() {
        return "Standard" + index;
    }

    @Override
    protected List<MenuBean> getMenuBeans() {
        List<MenuBean> menuBeans = new ArrayList<>();
        menuBeans.add(new MenuBean()
                .setMenuTitle("当前启动模式:" + title)
                .setMenuSubTitle("ACTIVITY地址:\n" + this.toString())
        );
        menuBeans.add(new MenuBean().setMenuTitle("跳转standard")
                .setMenuSubTitle("默认的启动模式")
                .setOnClickListener(view -> startActivity(NormalActivity.newIntent(getContext(), "standard", index)))
        );
        menuBeans.add(new MenuBean()
                .setMenuTitle("跳转singleTop")
                .setMenuSubTitle("")
                .setOnClickListener(view -> startActivity(SingleTopActivity.newIntent(getContext(), "singleTop", index))
                ));
        menuBeans.add(new MenuBean()
                .setMenuTitle("跳转singleTask")
                .setMenuSubTitle("")
                .setOnClickListener(view -> startActivity(SingleTaskActivity.newIntent(getContext(), "singleTask", index)
                )));
        menuBeans.add(new MenuBean()
                .setMenuTitle("跳转singleInstance")
                .setMenuSubTitle("")
                .setOnClickListener(view -> startActivity(SingleInstanceActivity.newIntent(getContext(), "singleInstance", index)))
        );
        return menuBeans;
    }

}
